#pragma once

#include "CalibData.h"

#include <vector>

#ifndef ROOT_TGTab
#include <TGTab.h>
#endif

#ifndef ROOT_TGTextEntry
#include <TGTextEntry.h>
#endif

#include "ArchiveWrapper.h"
#include "Exceptions.h"

class CalibTab
{
public:
    CalibTab(void);
    ~CalibTab(void);

    void Create( TGTab *fDataTabCalibTab, void* appPtr, std::string arcName );

    void ReadCalibrations(int shotNum);
    void ShowCalibrations( CalibData &calibrations);

    void GetCalib(CalibData &data)
    {
        GetSmallCalib(data.smallCalib);
        GetBgCalib(data.bgCalib);
        GetSpecCalib(data.spectralCalib);
        GetPeakCalib(data.peakRatioCalib);
    };
  
    void SetArcName(std::string arcName) { m_archiveName->SetText(arcName.c_str()); };

private:
    void CreateSmallCalib(TGCompositeFrame *fCalibTabFrame);
    void CreateBgCalib(TGCompositeFrame *fCalibTabFrame);
    void CreateSpecCalib(TGCompositeFrame *fCalibTabFrame);
    void CreatePeakCalib(TGCompositeFrame *fCalibTabFrame);

    // these functions will be called when corresponding save button is pressed
    // button Pressed() signal is handled by one of Save functions which then calls corresponding Get*Calib function to retrieve user inputs
    // also these functions are used when Calculate is pressed
    void GetSmallCalib( SmallCalibData &smallCalib );
    void GetBgCalib( BgCalibData &bgCalib );
    void GetSpecCalib( SpectralCalibData &specCalib );
    void GetPeakCalib( PeakRatioCalibData &peakCalib );

private:

    std::vector< std::pair<TGTextEntry*, const char*> > m_smallCalib;
    std::vector< std::pair<TGTextEntry*, TGTextEntry*> > m_backgroundCalib;
    std::vector< std::vector<TGTextEntry*> > m_spectralCalib;
    std::vector< std::pair<TGTextEntry*, TGTextEntry*> > m_peakCalib;

    TGTextEntry *m_archiveName;
};

